package com.hzqx.syndata.threadpool;


import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
//        Executors.newFixedThreadPool(5);
//        Executors.newCachedThreadPool();

/**
 * 学习线程池,此类中Executors的三大方法来创建线程池
 * @author yinzhiping
 */
public class ThreadPoolTest {
    public static void main(String[] args) {
        ExecutorService executorService = Executors.newSingleThreadExecutor();
        try {
            for (int i = 0; i < 10; i++) {
                executorService.execute(()->{
                    System.out.println(Thread.currentThread().getName()+"");
                });
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            executorService.shutdown();
        }
    }
}
